package n15.first;

import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class F01 {

	public static void main(String[] args) {
		String[]ps= {"zhangsan", "lisi", "wangwu", "lisi"};
		//(1)流中数据收集到 List
		List<String> list = Stream.of(ps).collect(Collectors.toList());
		System.out.println(list);
		//(2)流中数据收集到 Set
		Set<String> set = Stream.of(ps).collect(Collectors.toSet());
		System.out.println(set);
		//(3)流中数据收集到 Map
		Map<String, Integer> map = Stream.of(ps).distinct().collect(Collectors.toMap(p->p, p->p.length()));
		map.forEach((k,v)->System.out.println("\t"+k+"\t"+v));
		//(4)流中数据收集到 ArrayList
		ArrayList<String> arrayList = Stream.of(ps).collect(Collectors.toCollection(ArrayList::new));
		System.out.println(arrayList);
		//(5)流中数据收集到 HashSet
		HashSet<String> hashSet = Stream.of(ps).collect(Collectors.toCollection(HashSet<String>::new));
		System.out.println(hashSet);
		//(5)流中数据收集到 LinkedHashSet, 有序的
		LinkedHashSet<String> linkedHashSet = Stream.of(ps).collect(Collectors.toCollection(LinkedHashSet<String>::new));
		System.out.println(linkedHashSet);

	}

}
